<?php
class carte {
	public $iso;
	public $entite;
	public $text = array();

	public function __construct($i,$e,$t) {
		$this->iso = $i;
		$this->entite = $e;
		$this->text[] = $t;
	}

	public function add_ent($ent){
			$this->entite=$ent;
	}

	public function add_text($s){
		if(!in_array($s,$this->text))
			$this->text[] = $s;
	}
}

class carte_data{
	public $data = array();

	public function add_carte($iso,$entite,$text){
		$find=0;
		foreach($this->data as $d){
			if($d->iso == $iso){
				$find = 1;
				$d->add_ent($entite);
				$d->add_text($text);
			}
		}
		if($find==0) $this->data[] = new carte($iso,$entite,$text);
	} 
	
	public function echo_table(){
		echo "[";
		$i = 0;
		foreach($this->data as $d){
			if($i!=0)echo ",";
			echo "['".$d->iso."',".$d->entite.",'".implode($d->text," et ")."']";
			$i++;
		}
		echo "]";
	}
}

?>
